﻿using Engine;
using Engine.Graphics;
using Game;

namespace SAGhoul.Blocks
{
    public class BizarrebombBlock : Block
    {
        public BlockMesh m_standaloneBlockMesh = new();

        public override void Initialize()
        {
            Model model = ContentManager.Get<Model>("Models/Bomb");
            Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Bomb").ParentBone);

            m_standaloneBlockMesh.AppendModelMeshPart(
                model.FindMesh("Bomb").MeshParts[0],
                boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.25f, 0f),
                makeEmissive: false,
                flipWindingOrder: false,
                doubleSided: false,
                flipNormals: false,
               new Color(1f, 0.84f, 0f)
            );

            base.Initialize();
        }

        public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
        {
        }

        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMesh, color, 2f * size, ref matrix, environmentData);
        }
    }
}